<template>
	<div>
		<HomeHeader></HomeHeader>
		<HomeLeft :cur="10"></HomeLeft>
		<div id="main">
			<div id="web_con">
				<div class="web_wp">
					<div class="web_location">
						<div class="here_area">
							<strong>当前位置：</strong>修改密码
						</div>
					</div>

					<div class="tabTitle">
						<ul class="clearfix">
							<li class="cur"><a href="javascript:;">基本信息</a></li>
						</ul>
						<div class="tabCont">
							<div class="cont">
								<table class="dataTable">
									<tr>
										<td class="ltd">原密码</td>
										<td class="rtd">
											<input type="password" class="input-text" v-model="yuan_pwd">
										</td>
									</tr>
									<tr>
										<td class="ltd">新密码</td>
										<td class="rtd">
											<input type="password" class="input-text" v-model="password">
										</td>
									</tr>
									<tr>
										<td class="ltd">确认密码</td>
										<td class="rtd">
											<input type="password" class="input-text" v-model="passwordtwo">
										</td>
									</tr>
								</table>
							</div>
						</div>
					</div>

					<div>
						<div class="contBtn">
							<table class="dataTable">
								<tfoot>
									<tr>
										<td class="ltd"></td>
										<td class="rtd">

											<a href="javascript:;" class="web_btn btn_add" @click="SubMit()"><em
													class="iconfont icon-shdcbaocun"></em>确定修改
											</a>
										</td>
									</tr>
								</tfoot>
							</table>
						</div>
					</div>

				</div>

			</div>
		</div>
	</div>
</template>

<script>
	import HomeHeader from '../components/Header.vue';
	import HomeLeft from '../components/Left.vue';
	export default {
		components: {
			HomeHeader,
			HomeLeft,
		},
		data() {
			return {
				yuan_pwd: '',
				password: '',
				passwordtwo: '',
			}
		},
		onLoad(e) {
			let that = this;
		},
		methods: {


			//保存
			SubMit: function() {
				let that = this;

				if (that.yuan_pwd == '') {
					uni.showToast({
						icon: 'none',
						title: '请输入原密码',
						duration: 2000
					});
				} else if (that.password == '') {
					uni.showToast({
						icon: 'none',
						title: '请输入新密码',
						duration: 2000
					});
				} else if (that.passwordtwo == '') {
					uni.showToast({
						icon: 'none',
						title: '请输入确认密码',
						duration: 2000
					});
				} else if (that.passwordtwo != that.password) {
					uni.showToast({
						icon: 'none',
						title: '两次密码不一致',
						duration: 2000
					});
				} else {
					let _data = {
						yuan_pwd: that.yuan_pwd,
						pwd: that.password
					}
					that.common.http('POST', 'update_pwd', _data, function(res) {
						uni.hideLoading();
						uni.showToast({
							icon: 'none',
							title: '操作成功！',
							duration: 2000
						});
						setTimeout(function() {
							that.navigateBack();
						}, 1500);
					});
				}
			},

			navigateBack() {
				// #ifdef H5
				const pages = getCurrentPages()
				if (pages.length > 1) {
					uni.navigateBack(1)
					return;
				}
				//使用vue-router返回上一级
				let a = this.$router.go(-1)
				if (a == undefined) {}
				return;
				// #endif
				uni.navigateBack();
			},

		}
	}
</script>

<style>


</style>